package com.itheima.eurekaprovider.controller;

import com.itheima.eurekaprovider.entity.User;
import com.itheima.eurekaprovider.service.PortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ProviderController {
    @Autowired
    PortService portService;
   @GetMapping(value="/hello")
    public String sayHello() {
       String s = "Hello Feign! from provider\n" + portService.getPort();
        return s;
    }
    @GetMapping(value="/hello2")
    public String sayHello(String username,Integer age) {
        String s = "Hello Feign! from provider\n"
                + portService.getPort()
                + " 参数="+username+" "+age;
        return s;
    }
    @PostMapping(value="/hello3")
    public String sayHello2(User user) {
        System.out.println(user);
        String s = "Hello Feign! from provider /hello3 绑定 \n"
                + portService.getPort()
                + " 参数="+user;
        return s;
    }

    @PostMapping(value="/hello4")
    public String sayHello(@RequestBody User user) {
    //此处放入 学号:姓名:机器名
        String mid = "[学号:姓名:机器名]";
        String s = "Hello Feign! from provider \n" + mid + " "
                + portService.getPort()
                + " 参数="+user;
        return s;
    }
}
